﻿
google.load('search', '1', { language: "zh-CN" });
google.setOnLoadCallback(function () {
    $(function () {
        var customSearchControl = new google.search.CustomSearchControl('004444445504374248743:pn98cdeq3ys');
        customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
        customSearchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
        var options = new google.search.DrawOptions();
        options.setSearchFormRoot('cse-search-form');
        customSearchControl.setSearchCompleteCallback(this, function () {
            $("#google-search-result .loading-icon").hide();
            $("#result-container *").remove();
            $("#cse .gs-result").remove().appendTo($("#result-container"));
            $("#result-container").show();
        });
        customSearchControl.setSearchStartingCallback(this, function () {
            $("#google-search-result .loading-icon").show();
            $("#result-container").hide();
            $("#google-search-result").show();
        });
        customSearchControl.draw('cse', options);
        $(".gsc-clear-button").click(function () {
            $("#google-search-result").hide();
        });
    });
}, true);